package com.guaoran.interview.spring.autowired.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.SQLOutput;

/**
 * @author : 孤傲然
 * @description :  {@link Transactional} 注释到类上，会有事务
 * 当类上没有{@link Transactional} 注解时， 方法{@link #say()} 调用 {@link #say2()} 是不会进行事务代理的
 *
 * @date :2020/1/3 16:24
 */
//@Transactional
@Service
public class Transaction2Service {

    public String say(){
        System.out.println("Transaction2Service ... say");
        this.say2();
        return null;
    }
    @Transactional
    public String say2(){
        System.out.println("Transaction2Service ... say2");
        return null;
    }

    @Transactional
    public String say3(){
        System.out.println("Transaction2Service ... say3");
        throw new RuntimeException();

    }
}
